<template>
    <div>
        <el-dialog title="编辑" :visible.sync="centerDialogVisible" width="60%" center :modal="true">
            <el-form ref="form" :model="thisEditData" label-width="150px">
                <el-form-item label="用户名">
                    <el-input v-model="thisEditData.customer_name" width="60%"></el-input>
                </el-form-item>
                <el-form-item label="用户密码">
                    <el-input v-model="thisEditData.customer_password" width="60%"></el-input>
                </el-form-item>
                <el-form-item label="用户类型">
                    <el-select v-model="thisEditData.customer_type" width="60%" placeholder="请选择用户类型">
                        <el-option label="超级会员" value="超级会员"></el-option>
                        <el-option label="普通会员" value="普通会员"></el-option>
                        <el-option label="普通用户" value="普通用户"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="用户年龄">
                    <el-input v-model="thisEditData.customer_age" width="60%"></el-input>
                </el-form-item>
                <el-form-item label="用户真实姓名">
                    <el-input v-model="thisEditData.customer_reallyName" width="60%"></el-input>
                </el-form-item>
                <el-form-item label="用户性别">
                    <el-select v-model="thisEditData.customer_sex" width="60%" placeholder="请选择用户性别">
                        <el-option label="男" value="1"></el-option>
                        <el-option label="女" value="0"></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="childCenterDialogVisibleChange">取 消</el-button>
                <el-button type="primary" @click="onSubmit">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import { submitCustomerEdit } from '../../../api/index';
export default {
    data() {
        return {
            thisEditData: this.editData
        };
    },
    computed: {
        // thisEditData:function() {
        //     return this.editData
        // }
    },
    watch: {
        editData(newVal, oldVal) {
            this.thisEditData = newVal;
        }
    },
    methods: {
        childCenterDialogVisibleChange: function () {
            this.$emit('parentCenterDialogVisibleChange', this.centerDialogVisible);
        },
        onSubmit() {
            console.log(this.editData.customer_age, 'editData');
            console.log(this.thisEditData, 'thisEditData');
            // const params = `customer_id=${this.thisEditData.customer_id}&customer_type=${this.thisEditData.customer_type}`;
            const params = {
                customer_id: this.editData.customer_id,
                customer_type: this.editData.customer_type,
                customer_age: this.thisEditData.customer_age,
                customer_name: this.thisEditData.customer_name,
                customer_password: this.thisEditData.customer_password,
                customer_reallyName: this.thisEditData.customer_reallyName,
                customer_sex: this.thisEditData.customer_sex
            };
            console.log(this.thisEditData.customer_type, 'this.editData.customer_type');
            submitCustomerEdit(params).then((res) => {
                console.log(res)
                if (res) {
                    if (res === 'ok') {
                        this.$message({
                            message: '编辑成功',
                            type: 'success'
                        });
                    } else {
                        this.$message.error('编辑失败');
                    }
                }
            });
        }
    },
    props: ['centerDialogVisible', 'editData']
};
</script>

<style scoped>
/* .el-input{
    display: ;
} */
</style>